import * as echarts from 'echarts'
import chinaData from '../data/china.json'
export default function (el: HTMLElement) {
  const echartsInstance = echarts.init(el)
  const setOptions = (options: any) => {
    echartsInstance.setOption(options)
    echarts.registerMap('china', chinaData)
  }
  const updataResize = () => {
    echartsInstance.resize()
  }
  window.addEventListener('resize', () => {
    echartsInstance.resize()
  })
  return {
    echartsInstance,
    setOptions,
    updataResize
  }
}
